﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GBMS.IBLL;
using KPIS.GERP.GBMS.MODEL;
using KPIS.GERP.GBMS.DAL;
using KPIS.GERP.GBMS.DAL;
using KPIS.GERP.GBMS.DALFactory;

namespace KPIS.GERP.GBMS.BLL
{
    public sealed class ProjectRequestBLL : IProjectBLL
    {
        private static readonly IProjectRequestDAL dal = DataAccess.CreateProject();
        private IProjectRequestDAL prjDAL =  new ProjectRequestDAL();

        public void Insert(string code, string name, string descr, string monthstart, string monthend, string reason, string objects, string target, string plan, string detail, string remark, string strategy, string jobsite, string year)
        {
            ProjectInfo pjInfo = new ProjectInfo(0, code, name, descr, DateTime.Today, monthstart, monthend, reason, objects, target, plan, detail, remark, strategy, jobsite, Convert.ToInt32(year), "", new UserRecordInfo(1, null));

            if (dal.Insert(pjInfo) > 0)
            {

            }
            else
            {

            }
        }

        public void Update(string seq, string code, string name, string descr, string monthstart, string monthend, string reason, string objects, string target, string plan, string detail, string remark, string strategy, string jobsite, string year)
        {
            ProjectInfo pjInfo = new ProjectInfo(Convert.ToInt32(seq), code, name, descr, DateTime.Today, monthstart, monthend, reason, objects, target, plan, detail, remark, strategy, jobsite, Convert.ToInt32(year), "", new UserRecordInfo(null, 1));

            if (dal.Update(pjInfo) > 0)
            {

            }
            else
            {

            }
        }

        public void Delete(string seq)
        {
            //if (dal.Delete(Convert.ToInt32(seq)) > 0)
            //{

            //}
            //else
            //{

            //}
        }

        public IList<ProjectInfo> Search(ProjectInfo pjCritiria)
        {
            return prjDAL.Search(pjCritiria);
        }

        public DataSet GetProjectTotalBudget(int reqSeq)
        {
            return prjDAL.GetProjectTotalBudget(reqSeq);
        }
    }
}
